package k4_thread.demo05;

public class Number implements Runnable {

    @Override
    public void run() {

        int num = 100;

        String threadName = Thread.currentThread().getName();
        if(threadName.equals("守护")){
            num = 300;
        }

        while(num>0){
            System.out.println(Thread.currentThread().getName()+":"+num--);

            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}

class Test{
    public static void main(String[] args) {

        Thread normal = new Thread(new Number(),"普通");
        System.out.println(normal.getPriority());
        normal.start();

        Thread daemon = new Thread(new Number(),"守护");
        daemon.setDaemon(true);
        System.out.println(daemon.getPriority());
        daemon.start();
    }
}